package maquinavotar.utils;

import java.util.*;

public class RandomizingTool {

    private static Random r = null;
        
    public static int getNumber() {
        if(r == null) {
            r = new Random();
            r.setSeed(new Date().getTime());
        }
        return r.nextInt(1000);
    }
    
    public static Object[] getVectorRandom(Object[] arr) {
        if(arr == null)
            return null;
        for(int i=0; i<arr.length; i++) {
            int pos_random = RandomizingTool.getNumber() % arr.length;
            Object tmp = arr[i];
            arr[i] = arr[pos_random];
            arr[pos_random] = tmp;
        }
        return arr;
    }
    
    public static ArrayList getArrayRandom(ArrayList arr) {
        if(arr == null)
            return null;
        for(int i=0; i<arr.size(); i++) {
            int pos_random = RandomizingTool.getNumber() % arr.size();
            Object tmp = arr.get(i);
            arr.set(i, arr.get(pos_random));
            arr.set(pos_random, tmp);
        }
        return arr;
    }
    
}